home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / general.programming / comp.lang.c_12207_000016.msg < prev    next >
Encoding:
Text File  |  1994-11-27  |  2.3 KB  |  43 lines

  1. Newsgroups: comp.lang.c++,comp.lang.c
  2. Path: dd.chalmers.se!news.chalmers.se!sunic!trane.uninett.no!eunet.no!EU.net!howland.reston.ans.net!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
  3. From: mccall@mksol.dseg.ti.com (Fred McCall)
  4. Subject: Re: Here's a neat idiom for y'all...
  5. Message-ID: <1994Mar22.163726.18125@mksol.dseg.ti.com>
  6. Followup-To: comp.lang.c++,comp.lang.c
  7. Organization: Texas Instruments Inc
  8. X-Newsreader: TIN [version 1.2 PL0]
  9. References: <CMu245.DE3@marin.cc.ca.us> <2mb4hs$4vs@crl.crl.com>  <lfw.763998847@pssparc2.oc.com> <2mdapj$9ph@crl2.crl.com> <EJH.94Mar21140731@larry.gsfc.nasa.gov> <2ml75l$d00@chico.staf.phil.ruu.nl>
  10. Date: Tue, 22 Mar 1994 16:37:26 GMT
  11. Lines: 29
  12. Xref: dd.chalmers.se comp.lang.c++:14006 comp.lang.c:12207
  13.  
  14. Hendrik Jan Veenstra (hjv@phil.ruu.nl) wrote:
  15.  
  16. : But, as some other have pointed out already, this usage is fairly non-standard
  17. : and for many (including myself) it's 'strange' to read.  It just don't look
  18. : good...
  19. : What you want to do is compare ptr to NULL -- i.e. 'if ptr equal to NULL...',
  20. : which would be translated to C thus: "if (ptr == NULL)...".  For me 'if NULL is
  21. : equal to ptr' is illogical, irritating, annoying, silly, ...&*&#$*  :-)
  22.  
  23. Well, some of us find the overly-verbose 'if (ptr == NULL)'
  24. "illogical, irritating, annoying, silly, ..." and prefer to write it
  25. as 'if (!ptr)'.  This makes prefectly good sense if one merely
  26. remembers that a pointer with a nil value is a pointer which does not
  27. point to a legal object -- in other words, it is an 'un-pointer'.
  28.  
  29. : ANd besides, any half-decent compiler will emit a warning on construct like
  30. : "if (a = b)", so the probelm is non-existent to begin with.
  31.  
  32. I hate compilers that do this.  It's one of those messages I turn off
  33. (because this isn't a mistake that I, personally, make -- I make other
  34. mistakes, instead -- and because there are a lot of times when I *am*
  35. doing an assignment in the conditional clause and I don't want my real
  36. errors obscured by a bunch of noisy warnings).
  37.  
  38. -- 
  39. "Insisting on perfect safety is for people who don't have the balls to live
  40.  in the real world."   -- Mary Shafer, NASA Ames Dryden
  41. ------------------------------------------------------------------------------
  42. Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
  43.